package rush.rushcampus.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import rush.rushcampus.common.Result;
import rush.rushcampus.dto.ArticleTagDto;
import rush.rushcampus.entity.ArticleTag;
import rush.rushcampus.service.IArticleTagService;
import rush.rushcampus.service.IUserService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author rush
 * @since 2024-06-11
 */
@RestController
@Api(tags = "文章标签管理")
@RequestMapping("/article-tag")
public class ArticleTagController {

    @Autowired
    private IArticleTagService articleTagService;
    @Autowired
    private IUserService userService;
    //查询文章标签

    @ApiOperation(value = "查询文章标签")
    @GetMapping("/list")
    public Result list() {
        return Result.success(articleTagService.list());
    }

    //添加文章标签
    @ApiOperation(value = "添加文章标签")
    @PostMapping("/add")
    public Result addArticleTag(@RequestBody ArticleTagDto articleTagDto) {
        articleTagService.addArticleTag(articleTagDto);
        return Result.success("添加成功");
    }
    //根据id查询标签
    @ApiOperation(value = "根据id查询标签")
    @GetMapping("/getById")
    public Result getById(@RequestParam Long id) {
        return Result.success(articleTagService.getTag(id));
    }
    //用户关注
    @ApiOperation(value = "用户关注")
    @GetMapping("/concern")
    public Result concern(@RequestParam Long id) {
        userService.concern(id);
        return Result.success("关注成功");
    }
}
